#include <iostream>
using namespace std;

/*动物类*/
class Animal
{

public:
    /*叫*/
    /*虚函数就是被virtual修改的成员函数*/
    virtual void speak()
    {
        cout << "Animal::speak()" << endl;
    }

    /*跑*/
    virtual void run()
    {
        cout << "Animal::run()" << endl;
    }

private:
    int m_age;
};

/*牛*/
class Cow : public Animal
{
public:
    /*叫*/
    void speak()
    {
        cout << "Cow::speak()mou mou mou..." << endl;
    }
    /*跑 */
    void run()
    {
        cout << "Cow::run() mou mou mou..." << endl;
    }

private:
    /*颜色 */
    char m_color[24];
};

class Horse : public Animal
{
public:
    /*叫*/
    void speak()
    {
        cout << "Cow::speak()lv lv lv..." << endl;
    }
    /*跑 */
    void run()
    {
        cout << "Cow::run() lv lv lv..." << endl;
    }
    /*马的品种*/
    char m_type[24];
};

class CowHorse : public Animal
{
public:
    void speak()
    {
        cout << "CowHorse::run()收到,好的" << endl;
    }
    /*跑*/
    void run()
    {
        cout << "CowHorse::run()摆了 摆了 摆了" << endl;
    }
}

int
main()
{
#if 0
    /*类对象 */
    Animal ani;
   cout << "size"<<sizeof(ani)<< endl;

    ani.speak();
    ani.run();
    /*牛*/
    Cow cow;
    cow.speak();
    cow.run();
    /*马*/
    Horse horse;
    horse.speak();
    horse.run();
#endif

#if 0
    /*多态的使用 */
    /*父类指针指向子类对象 */
    Animal *ani = new Cow;
    /*父类指针调用重写的成员函数*/
    ami->speak();
    Animal *ani2 = new Horse;
    ani2->speak();
#endif

    return 0;
}
